<?php

require_once  dirname(__FILE__).'/../code/CV.php';
CV::init();


class CV_Testsuite extends CV_Unittest_Suite_Collecting{
	public function __construct( $requested_tests = "", $title = "ScoutNet-Kalender Testsuite" ){
		class_exists( 'WebTestCase' );
		class_exists( 'UnitTestCase' );
		class_exists( 'CV_Unittest_Case' );
		$tests = CV::realpath( dirname(__FILE__),'..','tests','CV' ) . DIRECTORY_SEPARATOR . $requested_tests;
		parent::__construct( $tests, $title );
	}	
}

if( __FILE__ === realpath($_SERVER['SCRIPT_FILENAME']) ){
	if( isset($_SERVER['argv'][1]) ){
		$suite = new CV_Testsuite( $_SERVER['argv'][1] );
	} elseif( isset($_GET['test']) ){
		$suite = new CV_Testsuite( $_GET['test'] );
	} else {
		$suite = new CV_Testsuite();
	}
	
	if( true === $suite->run() ){
		exit(0);
	} else {
		exit(1);
	}
}